﻿using Furion.DynamicApiController;
using HOPU.OnlineSchool.Application.Teachers.Dtos;
using HOPU.OnlineSchool.Application.Teachers.Services;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HOPU.OnlineSchool.Application.Teachers
{
    public class TeacherAppService : IDynamicApiController
    {
        private readonly ITeacherService _teacherService;

        public TeacherAppService(ITeacherService teacherService)
        {
            _teacherService = teacherService;
        }
        /// <summary>
        /// 分页查询讲师信息
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="listInput"></param>
        /// <returns></returns>
        public async Task<PagedList<TeacherListOutput>> List(int page,int limit,TeacherListInput listInput)
        {
            var list = await _teacherService.GetPagedListAsync(page, limit, listInput);
            return list;
        }
        /// <summary>
        /// 删除讲师
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<string> Delete(string id)
        {
            await _teacherService.DeleteAsync(id);
            return "删除成功！";
        }
        /// <summary>
        /// 添加讲师
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<string> Add(TeacherAddInput input)
        {
            await _teacherService.AddAsync(input);
            return "添加成功！";
        }
        /// <summary>
        /// 根据id获取编辑讲师信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<TeacherDto> Get(string id)
        {
            var result= await _teacherService.GetTeacherAsync(id);
            return result;
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="id"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<string> Update(string id,[FromBody] TeacherDto input)
        {
            await _teacherService.UpdateAsync(id, input);
            return "更新成功";
        }
    }
}
